package com.piddock.gol2;

import android.app.Application;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.SimpleCursorAdapter;

public class GuideofLegends2Activity extends ListActivity {

	private LeagueDbAdapter mDbHelper;
	public static final int MENU_CHAMPIONS_ID = Menu.FIRST;
	public static final int MENU_ITEMS_ID = Menu.FIRST;
	public static final int MENU_BUILDS_ID = Menu.FIRST;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		System.out.print(Application.class.getPackage().getName()); 
		setContentView(R.layout.champion_list);
		mDbHelper = new LeagueDbAdapter(this);
		mDbHelper.open();
		fillData();

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		boolean result = super.onCreateOptionsMenu(menu);
		menu.add(0, MENU_CHAMPIONS_ID, 0, R.string.menu_champions);
		menu.add(0, MENU_ITEMS_ID, 0, R.string.menu_items );
		menu.add(0, MENU_BUILDS_ID, 0, R.string.menu_builds );
		return result;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {
		case MENU_CHAMPIONS_ID:
			displayChampions();
			return true;

		}
		return super.onOptionsItemSelected(item);
	}

	public void displayChampions(){}
	
	
//	private void createNote() {
//		String ChampionName = "Champion " + mChampionNumber++;
//		mDbHelper.createChampion(ChampionName, "");
//		fillData();
//	}

	private void fillData() {
		Cursor c = mDbHelper.fetchAllChampions();
		startManagingCursor(c);

		String[] from = new String[] { LeagueDbAdapter.KEY_NAME };
		int[] to = new int[] { R.id.champion_name_text};

		SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
				R.layout.champion_list_item, c, from, to);
		setListAdapter(notes);
		

	}
}